package com.newtouch.bxzs.business.product.controller;

import com.newtouch.bxzs.business.product.model.UserBO;
import com.newtouch.bxzs.business.product.service.UserService;
import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 接口规范demo的controller类
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2020年12月14日</td>
 * <td>Amour</td>
 * <td>Create</td>
 * </tr>
 * </table>
 * 
 * @author Amour
 * 
 * @version 1.0.0
 * @since 1.0.0
 */

@RestController
@RequestMapping("/userController")
public class UserController {

	/** 静态变量：系统日志 */
	private static final Log logger = LogFactory.getLog(UserController.class);

	@Autowired
	private UserService userService;

	/**
	 * 根据姓名获取user信息
	 * 
	 * @param name
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@GetMapping("/getUserByName")
	public BaseResponse<List<UserBO>> listUsers(@RequestParam(value = "name", required = false) String name) {
		logger.info("根据姓名获取user信息");
		return RespGenerator.returnOK(userService.getUserByName(name));
	}
}